Robotics 1.0 Lesson Plan
Lesson 6 - Light up the Day!

Purpose:Use the CPX’s onboard light sensor and a relay to control an externally powered light by toggling it ON/OFF based on detected light levels.

No. of Classes

1 class (Duration: 1 hour 30 minutes; maximum 4 students per group).

Materials Required
  • Software
  • Laptop or desktop with Mu Editor installed.

    Circuit Playground Express (CPX) board with USB cable

    Relay.

    External battery.

    Bulb.

    Jumper wires.

Prior knowledge

Know how to open Mu Editor and select CircuitPython mode. Be familiar with writing and saving code.py to CPX

Exercises

Exercise:1



Read the Light sensor value from CPX.

Click here to view the instructions and code

Exercise:2



`

Using relay to set up the circuit


Connection part:

Click here to view the instructions and code

Relay switching ON and OFF

Exercise:3



Switching on an externally powered light when darkness is detected.


Here is a document showing code hints (pseudocode):

Click here to view the it.
Teacher's Instruction
  1. Go around and check if students are facing any issues, and help them troubleshoot.
  2. Click here to know more about Relay working. Children can see the GIF images that show the relay switching between ON and OFF states.
  3. Encourage students to use functions to read sensor values.
  4. Emphasize safety when using external batteries.
  5. Ask why we need to continuously check the light sensor value.
  6. How could this be used in real life (automatic lamps, alarms, etc.)?
  7. Discuss why a 9V battery is not sufficient to turn the light on.
  8. Discuss with students why external power is required and why the light cannot be connected directly to the board as done earlier.